<template>
<div class="common-body-wrapper">
  <search-header single-width="150" :searchList="searchList" @changeHeight="toRetTable" @confirmSearch="toSearch" :isNeedTree="true" :isCheckbox="true" :paramName="paramName" @setSelectedNode="setSelectedNode"></search-header>
  <multi-fun-table :sortColumn="notFormatColumn" :orderType="sortType" :fixed-cols="fixedCols" :is-reset-table="isResetTable" :theads-info="theadsInfo" :tbodys-info="tbodysInfo" @handleMultiCheck="handleMultiCheck" @handleSortColumn="handleSortColumn" @searchFn="getList" @getNextPage="getNextPage">
    <div class="operate-btn-group" slot="operateBtnGroup">
      <a class="ake_btn ake_btn_text" v-if="isPermmited('TRADER_COUPON:COUPON:SELL:SELL')" @click.prevent="SellCouponsModal_open()">销售优惠券</a>
      <a class="ake_btn ake_btn_text" v-if="isPermmited('TRADER_COUPON:COUPON:SELL:SELL')" @click.prevent="importSell()">批量销售</a>
      <a class="ake_btn ake_btn_text" v-if="isPermmited('TRADER_COUPON:COUPON:SELL:EXPORT')" @click.prevent="exportPDF()">导出纸质券</a>
      <a class="ake_btn ake_btn_text" v-if="isPermmited('TRADER_COUPON:COUPON:SELL:EXPORT')" @click.prevent="exportSell()">导出售卖记录</a>
      <a class="ake_btn ake_btn_text" v-if="isPermmited('TRADER_COUPON:COUPON:SELL:EXPORT')" @click.prevent="exportCouponSn()">导出优惠券编码</a>
      <a class="ake_btn ake_btn_text" v-if="isPermmited('TRADER_COUPON:COUPON:SELL:REFUND')" @click.prevent="batchRefund()">批量退款</a>
    </div>
    <template slot="tdCell" slot-scope="props">
      <el-table-column v-if="props.isMultiHeader" :label="props.label" align="center">
        <template v-for="(item, index) in props.children">
          <el-table-column v-if="item.checked" :key="index" :label="item.text" :min-width="item.minWidth" :width="item.width" :prop="item.prop" :sortable="item.sortable"></el-table-column>
        </template>
      </el-table-column>
      <el-table-column v-else :fixed="props.fixed" :label="props.label" :min-width="props.minWidth" :width="props.width" :prop="props.prop" :sortable="props.sortable">
        <template slot-scope="scope">
          <span v-if="'reno' == props.prop">{{scope.$index+1}}</span>
          <span v-else-if="'createTime' == props.prop && scope.row['createTime']">{{scope.row['createTime'] | mileSecondToDate}}</span>
          <span v-else-if="'refundTime' == props.prop && scope.row['refundTime']">{{scope.row['refundTime'] | mileSecondToDate}}</span>

          <span v-else-if="'couponSn' == props.prop && scope.row[props.prop]">
            <a class="imgLink" @click="CouponListModal_open(scope.row['id'])">查看（{{scope.row['sellNum'] - scope.row['refundNum']}}）</a>
          </span>
          <span v-else-if="'sellMoney' == props.prop || 'refundMoney' == props.prop">{{scope.row[props.prop] | formatMoney}}</span>
          <span v-else>{{ scope.row[props.prop] }}</span>
        </template>
      </el-table-column>
    </template>
    <template slot="operateCell" slot-scope="props">
      <el-table-column :fixed="props.fixed" :label="props.label" width="90" class-name="operateCell">
        <template slot-scope="scope">
          <el-button size="small" type="primary" icon="icon-refund" class="ake-icon-font" title="现金退款" v-if="isPermmited('TRADER_COUPON:TRADER:MODIFY')" :disabled="!(scope.row['balanceType']===0 && scope.row['leftNum']!==0 && scope.row['refunder']==null && scope.row['settleStatus']!==0)" @click.prevent="refundModal_open(scope.row)" plain></el-button>
          <!-- <el-button size="small" type="primary" icon="icon-recover" class="ake-icon-font" title="回收预购" v-if="isPermmited('TRADER_COUPON:TRADER:MODIFY')" @click.prevent="refundModal_open(scope.row,'回收预购')" :disabled="scope.row['balanceType']!==0&&scope.row['leftNum']!==0&&scope.row['refunder']==null" plain></el-button> -->
        </template>
      </el-table-column>
    </template>
  </multi-fun-table>

  <table-pagination :size="total" :cur-page="pageNumber" @backData="getPagination"></table-pagination>

  <!--至少选择一项 modal-->
  <basic-modal ref="TipModal" bodyTxt="请至少选择一项">
    <h3 slot="title">温馨提示</h3>
    <div class="modal-footer" slot="modal-footer">
      <button class="ake_btn ake_btn_text modal-close ake_btn_confirm" @click="TipModal_confirm('至少选择一项', ['关闭'])">确认</button>
      <button class="ake_btn ake_btn_text modal-close" @click="closed('至少选择一项', ['关闭'])">取消</button>
    </div>
  </basic-modal>

  <!-- 退款modal -->
  <basic-modal ref="refundModal" width="580" customeClass="select-park-modal" static="true">
    <h3 slot="title">{{refundModalData.title}}</h3>
    <div class="modal-body" slot="modal-body">
      <el-form ref="refund_form" :model="refundModalData" :rules="refundrules" label-width="120px" label-position="left">
        <el-form-item prop="tmpName" label="优惠券：">
          <span>{{refundModalData.tmpName}}</span>
        </el-form-item>
        <div class="row-item">
          <el-form-item prop="sellNum" label="购买数量（张）">
            <span>{{refundModalData.sellNum}}</span>
          </el-form-item>
          <el-form-item prop="sellMoney" label="购买券总额（元）">
            <span>{{refundModalData.sellMoney}}</span>
          </el-form-item>
        </div>
        <el-form-item prop="grantNum" label="已发放数量（张）">
          <span>{{refundModalData.grantNum}}</span>
        </el-form-item>
        <el-form-item prop="usedNum" label="已使用数量（张）">
          <span>{{refundModalData.usedNum}}</span>
        </el-form-item>
        <div class="row-item">
          <el-form-item prop="refundNum" label="退款数量（张）">
            <span>{{refundModalData.refundNum}}</span>
          </el-form-item>
          <el-form-item prop="money" label="退款券总额（元）">
            <span>{{refundModalData.money}}</span>
          </el-form-item>
        </div>
        <el-form-item prop="refundMoney" label="退款额（元）">
          <el-input v-model.number="refundModalData.refundMoney"></el-input>
        </el-form-item>
        <el-form-item prop="refundRemark" label="备注">
          <el-input type="textarea" v-model="refundModalData.refundRemark"></el-input>
        </el-form-item>
      </el-form>
    </div>
    <div class="modal-footer" slot="modal-footer">
      <button type="button" class="ake_btn ake_btn_text ake_btn_confirm" @click="refundModal_save()">确认</button>
      <button class="ake_btn ake_btn_text modal-close" @click="closed('refundModal')">取消</button>
    </div>
  </basic-modal>

  <!-- 销售优惠券 -->
  <basic-modal ref="SellCouponsModal" width="640" customeClass="select-park-modal" static="true">
    <h3 slot="title">销售优惠券</h3>
    <div class="modal-body" slot="modal-body">
      <el-form ref="SellCoupons_form" :model="SellCouponsModalData.mainData" :rules="mainDatarules" label-width="80px" label-position="left">
        <div class="row-inline">
          <el-form-item prop="coupon" label="选择优惠券">
            <el-select v-model="SellCouponsModalData.mainData.coupon" :placeholder="SellCouponsModalData.placeholderStr" @change="Coupon_change()" filterable :filter-method="searchCoupon" popper-class="select-search-filter" @visible-change="allCoupon" @blur="couponBlurEvent" @focus="couponFocusEvent">
              <el-option v-for="(item,index) in SellCouponsModalData.select_list" :label="item.name" :value="index" :key="index" v-if="!item.isHidden">
                <span style="float: left">{{ item.name }}</span>
                <el-tooltip placement="bottom-start" style="float: right;" v-if="item.parkNameList && item.parkNameList.length">
                  <div slot="content">
                    <p v-for="park in item.parkNameList">{{park}}</p>
                  </div>
                  <span>{{ item.parkNameListStr }}</span>
                </el-tooltip>
              </el-option>
            </el-select>
          </el-form-item>
          <el-button size="small" type="primary" @click="SellCouponsModal_detail_open" class="select-park-btn ake_btn_text ake_btn" :disabled="SellCouponsModalData.mainData.coupon===0 || SellCouponsModalData.mainData.coupon ? false : true">查看详情</el-button>
        </div>

        <div class="row-inline">
          <el-form-item prop="traderName" label="选择商户">
            <el-input v-model.number="SellCouponsModalData.mainData.traderName" disabled placeholder="请选择"></el-input>
          </el-form-item>
          <el-button size="small" type="primary" @click="getTraderListModal_open()" class="select-park-btn ake_btn_text ake_btn" style="width: 75px">请选择</el-button>
        </div>

        <el-form-item label="券信息">
          <div class="coupon-info">
            <p>{{SellCouponsModalData.couponName}}</p>
            <p class="twoItem">
              <span>券折扣价：</span>
              <span>{{SellCouponsModalData.mainData.realPrice}} 元/张</span>
              <span style="text-decoration: line-through;" class="tip">(原价 {{SellCouponsModalData.mainData.originalPrice}} 元/张)</span>
            </p>
            <p class="twoItem">
              <span>剩余总数：</span>
              <span>{{SellCouponsModalData.mainData.totalAvilableToBuy}} 张</span>
              <span class="tip">(限购数量 {{SellCouponsModalData.mainData.maxBuyNum}} 张)</span>
            </p>
          </div>
        </el-form-item>

        <div class="row-inline">
          <el-form-item prop="sellNum" label="购买数量">
            <el-input v-model.number="SellCouponsModalData.mainData.sellNum" placeholder="请输入数量"></el-input>
          </el-form-item>
          <div class="grayChunk total">
            <span>总价：{{pay}}</span>
            <span class="unit">元</span>
          </div>
        </div>
        <el-form-item prop="sellMoney" label="商家折扣价">
          <el-input v-model.number="SellCouponsModalData.mainData.sellMoney" placeholder="请输入价格"></el-input>
          <span class="unit">元</span>
        </el-form-item>
      </el-form>
    </div>
    <div class="modal-footer" slot="modal-footer">
      <button type="button" class="ake_btn ake_btn_text ake_btn_confirm" @click="SellCouponsModal_save()">确认</button>
      <button class="ake_btn ake_btn_text modal-close" @click="closed('SellCouponsModal')">取消</button>
    </div>
  </basic-modal>

  <!-- 选择商户 -->
  <basic-modal ref="SelectMerchantsModal" static="true" width="1050">
    <h3 slot="title">选择商户</h3>
    <div class="modal-body ModalBody" slot="modal-body">
      <div class="HeadMSG">
        <el-form ref="form" :model="SelectMerchantsModalDataForm" label-width="80px" label-position="left">
          <el-form-item label="商家名称：">
            <el-input v-model="SelectMerchantsModalDataForm.name"></el-input>
          </el-form-item>
        </el-form>
        <el-button type="primary" icon="el-icon-search" class="ake_btn" @click="SelectMerchantsModalData_change">搜索</el-button>
      </div>

      <div class="tableDetial">
        <template>
          <el-table :data="SelectMerchantsModalData.tbodysInfo" border style="width:100%">
            <el-table-column v-for="(item,index) in SelectMerchantsModalData.theadsInfo" :prop="item.prop" :label="item.label" :min-width="item.minWidth"></el-table-column>
            <el-table-column label="操作" min-width="80">
              <template slot-scope="scope">
                <el-button type="primary" size="small" @click="handleEdit(scope.$index, scope.row)">选择</el-button>
              </template>
            </el-table-column>
          </el-table>
        </template>
        <el-pagination background layout="prev, pager, next" :current-page="SelectMerchantsModalData.pageNumber" :total="SelectMerchantsModalData.total" @current-change="getReportDetailPagination" @prev-click="prevPage" @next-click="nextPage"></el-pagination>
      </div>
    </div>
    <div class="modal-footer" slot="modal-footer">
      <button class="ake_btn ake_btn_text modal-close" @click="closed('SelectMerchantsModal', 2)">返回上一级</button>
    </div>
  </basic-modal>

  <basic-modal ref="SellCouponsModal_detail" static="true" width="640" :needModalFooter="false">
    <h3 slot="title">优惠券详情</h3>
    <div class="modal-body" slot="modal-body">
      <div class="SellCouponscss">
        <table>
          <tr>
            <td>券名称</td>
            <td>{{SellCouponsModalData_detial.name}}</td>
          </tr>
          <tr>
            <td>券类型</td>
            <td>{{SellCouponsModalData_detial.couponTypeStr}}</td>
          </tr>
          <tr v-if="SellCouponsModalData_detial.couponTypeId==4 && (SellCouponsModalData_detial.couponRuleId==0 || SellCouponsModalData_detial.couponRuleId==2)">
            <td>优惠类型</td>
            <td>
              <span>减去前面 {{SellCouponsModalData_detial.faceValue}}分钟的时长再计费</span>
            </td>
          </tr>
          <tr v-if="SellCouponsModalData_detial.couponTypeId==4 && (SellCouponsModalData_detial.couponRuleId==1 || SellCouponsModalData_detial.couponRuleId==3)">
            <td>优惠类型</td>
            <td>
              <span>减去后面 {{SellCouponsModalData_detial.faceValue}}分钟的时长再计费</span>
            </td>
          </tr>
          <tr v-if="SellCouponsModalData_detial.couponTypeId==1">
            <td>停车费优惠</td>
            <td>{{SellCouponsModalData_detial.faceValue}}元</td>
          </tr>
          <tr v-if="SellCouponsModalData_detial.couponTypeId==1 || (SellCouponsModalData_detial.couponTypeId==4 && SellCouponsModalData_detial.couponRuleId==0)">
            <td>是否可叠加</td>
            <td>
              <span>{{SellCouponsModalData_detial.isCoverStr}}</span>
              <span v-if="SellCouponsModalData_detial.isCover" class="grayTip">（一次停车最多使用 {{SellCouponsModalData_detial.maxCoverNum}}张）</span>
            </td>
          </tr>
          <tr v-if="SellCouponsModalData_detial.couponTypeId==2">
            <td>折扣</td>
            <td>{{SellCouponsModalData_detial.faceValue}}折</td>
          </tr>
          <tr v-if="SellCouponsModalData_detial.couponTypeId==3">
            <td>面值</td>
            <td>{{SellCouponsModalData_detial.faceValue}}元</td>
          </tr>
          <tr v-if="SellCouponsModalData_detial.couponTypeId==4 && (SellCouponsModalData_detial.couponRuleId==0 || SellCouponsModalData_detial.couponRuleId==1)">
            <td>享受免费时长</td>
            <td>{{SellCouponsModalData_detial.useParkingFee}}</td>
          </tr>
          <tr>
            <td>适用车场</td>
            <td>{{SellCouponsModalData_detial.parkNameListStr}}</td>
          </tr>
          <tr>
            <td>财务主体</td>
            <td>{{SellCouponsModalData_detial.financialParkIdStr}}</td>
          </tr>
          <tr>
            <td>使用有效期</td>
            <td>
              <span>领券后 {{SellCouponsModalData_detial.validDay}}分钟内使用</span>
              <span v-if="SellCouponsModalData_detial.expireRefund" class="grayTip">（逾期退回）</span>
            </td>
          </tr>
          <tr>
            <td>优惠券原价</td>
            <td>
              <span>{{SellCouponsModalData_detial.originalPrice}}元</span>
              <span class="grayTip">（折扣价：{{SellCouponsModalData_detial.realPrice}}元）</span>
            </td>
          </tr>
          <tr>
            <td>使用条件</td>
            <td>
              <span>停车费在</span>
              <span>{{SellCouponsModalData_detial.useRule}}</span>
              <span>可使用此优惠</span>
            </td>
          </tr>
          <tr>
            <td>券数量</td>
            <td v-if="SellCouponsModalData_detial.isLimitTotal">无限</td>
            <td v-else>
              <span>{{SellCouponsModalData_detial.totalNum}}</span>
              <span class="grayTip">（有限）</span>
            </td>
          </tr>
          <tr>
            <td>可售卖时间</td>
            <td>{{SellCouponsModalData_detial.sellFromTo}}</td>
          </tr>
          <tr>
            <td>可发放时间</td>
            <td>{{SellCouponsModalData_detial.validFromTo}}</td>
          </tr>
          <tr>
            <td>可线上购买券的商户</td>
            <td>{{SellCouponsModalData_detial.couponListStr}}</td>
          </tr>
        </table>
      </div>
    </div>
  </basic-modal>

  <basic-modal ref="CouponListModal" static="true" width="600">
    <h3 slot="title">优惠券编号</h3>
    <div class="modal-body" slot="modal-body">
      <button class="ake_btn ake_btn_text modal-close" @click.prevent="exportData()">导出</button>
      <div class="CouponListDetial">
        <el-table :data="CouponListModalData.list" border style="width: 100%" fit height="450">
          <el-table-column type="index" width="100"></el-table-column>
          <el-table-column prop="serialNumber" label="优惠券编码"></el-table-column>
        </el-table>
      </div>
    </div>
    <div class="modal-footer" slot="modal-footer">
      <button class="ake_btn ake_btn_text modal-close ake_btn_confirm" @click="closed('CouponListModal')">确定</button>
    </div>
  </basic-modal>

  <big-pic-modal ref="bigPicModal">
    <img slot="bigImgSlot" :src="bigImgPath | setImgPath" alt @error="imgError('../../', 'car', $event)" />
  </big-pic-modal>

  <!--导入-->
  <basic-modal ref="importModal" width="600" customeClass="import-modal" static="true">
    <h3 slot="title">批量销售优惠券</h3>
    <div class="modal-body" slot="modal-body">
      <el-form ref="importForm" :model="importFile" :rules="importRules" label-position="left" label-width="160px">
        <el-form-item label="下载模板" v-show="!importResult||importResult.processedCount==importResult.totalCount">
          <a class="text-btn ake-text-btn" href="javascript:;" @click="downloadTmp()">批量销售模板.xls</a>
        </el-form-item>

        <el-form-item label="选择文件" prop="importFile" v-show="!importResult||importResult.processedCount==importResult.totalCount">
          <input id="fileInput" type="file" @change="getFile($event)" class="first-item file-input" />
          <p class="help-block">支持.xls格式，大小不超过8.0M</p>
        </el-form-item>

        <el-form-item v-if="importResult && importResult.processedCount!=importResult.totalCount" label="正在处理中">
          <span v-if="importResult.processedCount!=importResult.totalCount">共{{importResult.totalCount}}条记录，当前已处理{{(importResult.processedCount/importResult.totalCount*100)|formatMoney}}%</span>
        </el-form-item>
        <el-form-item v-if="importResult && importResult.processedCount==importResult.totalCount" label="上次处理结果">
          <span v-if="importResult.successCount==importResult.totalCount">共{{importResult.totalCount}}条记录,全部成功(提示保留一天)</span>
          <span v-if="importResult.errorFileName">共{{importResult.totalCount}}条记录,失败{{importResult.failCount}}条,请下载失败文件,保留一天</span>
        </el-form-item>

        <el-form-item label="上次失败文件" v-show="importResult&&importResult.errorFileName">
          <a class="text-btn ake-text-btn text-btn_red" @click="downloadError()" href="javascript:;" v-text="importResult.errorFileName"></a>
        </el-form-item>

        <div class="import-notice">
          <span class>
            <h5>温馨提示：请按照以下步骤进行导入</h5>
            <p>1.请先下载模板文件，严格按照模板文件格式进行填写，不可更改文件格式。</p>
            <p>2.模板文件填写完成后，浏览选择文件，然后点击上传。</p>
            <p>3.如果上传失败，请下载失败文件，并注意失败原因的提示。重新填写上传。</p>
            <p>4.失败文件可直接编辑并上传。</p>
          </span>
        </div>
      </el-form>
    </div>
    <div class="modal-footer" slot="modal-footer">
      <button v-if="!importResult || importResult.processedCount==importResult.totalCount" class="ake_btn ake_btn_text ake_btn_confirm" @click.stop="sureImport($event)">确认</button>
      <button title="关闭当前窗口，已处理的请求不能取消" class="ake_btn ake_btn_text modal-close" @click="closed('importModal')">关闭</button>
    </div>
  </basic-modal>
</div>
</template>

<script>
import common from "@mixins/common.js";
import stardardList from "@mixins/tables/stardardList.js";

// z-tree
import "../../assets/js/libs/jquery.ztree.core.min.js";
import "../../assets/js/libs/jquery.ztree.excheck.min.js";
//modal
import invokeModal from "@mixins/modal/invokeModal.js";
import BigPicModal from "@components/widgets/BigPicModal.vue";

// image
import images from "@mixins/image.js";

// 引进vue的js
import c_sell from "./js/c_sell.js";
export default {
  name: "cSell",
  mixins: [common, stardardList, invokeModal, images, c_sell],
  components: {
    BigPicModal
  },
  data() {
    var checkNumber = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入购买数量"));
      } else if (!/^[1-9]+[0-9]*$/.test(value)) {
        return callback(new Error("请输入大于0的数量"));
      } else if (value > 100000) {
        callback(new Error("单次最多购买10万张"));
      } else if (
        this.SellCouponsModalData.mainData.maxBuyNum &&
        value > this.SellCouponsModalData.mainData.maxBuyNum
      ) {
        callback(new Error("购买数量超出限制数量"));
      } else if (
        this.SellCouponsModalData.mainData.totalAvilableToBuy &&
        value > this.SellCouponsModalData.mainData.totalAvilableToBuy
      ) {
        callback(new Error("购买数量超出剩余数量"));
      } else {
        callback();
      }
    };
    var checkMoney = (rule, value, callback) => {
      if (value === 0 || value === "0") {
        return callback();
      }
      if (!value || value == "" || value == null) {
        callback();
      } else if (!/^\d+(\.\d+)?$/.test(value)) {
        callback(new Error("请输入正确的金额"));
      } else if (value > this.SellCouponsModalData.mainData.totalMoney) {
        callback(new Error("商家折扣价不得大于总价"));
      } else {
        callback();
      }
    };
    var checkRefundMoney = (rule, value, callback) => {
      if (value === 0 || value === "0") {
        return callback();
      }
      if (!value || value == "" || value == null) {
        callback(new Error("请输入金额"));
      } else if (!/^\d+(\.\d+)?$/.test(value)) {
        callback(new Error("请输入正确的金额"));
      } else if (value > Number(this.refundModalData.money)) {
        callback(new Error("输入金额不得大于退款总额"));
      } else {
        callback();
      }
    };
    return {
      paramName: "query_parkId",
      fixedCols: 3,
      total: 0,
      //销售优惠券弹框的选择框里当前选择的优惠券
      currentCouponObj: {},
      // 退款选项
      refundModalData: {
        tmpName: "",
        sellNum: "",
        grantNum: "",
        usedNum: "",
        refundNum: "",
        money: "",
        sellMoney: "",
        refundMoney: "",
        refundRemark: ""
      },
      // 优惠券编号列表
      CouponListModalData: {
        list: []
      },
      SelectMerchantsModalData: {
        fixedCols: 3,
        tHeightModal: 300,
        list_data: {},
        pageNumber: 1,
        pageSize: 10,
        total: 0,
        theadsInfo: [{
            index: 1,
            prop: "name",
            label: "商家名称",
            minWidth: 100
          },
          {
            index: 2,
            prop: "contact",
            label: "联系人",
            minWidth: 100
          },
          {
            index: 3,
            prop: "tel",
            label: "联系电话",
            minWidth: 100
          },
          {
            index: 4,
            prop: "isLimitBuy",
            label: "是否限购"
          },
          {
            index: 5,
            prop: "maxBuyNum",
            label: "限制购买数"
          }
        ],
        tbodysInfo: []
      },
      SelectMerchantsModalDataForm: {
        name: ""
      },
      // 导出参数ID
      exportDataid: "",
      // 销售优惠券参数
      SellCouponsModalData: {
        couponName: "优惠券名称",
        select_list: [],
        mainData: {
          couponTmpId: "",
          coupon: "",
          realPrice: "",
          originalPrice: "",
          traderName: "",
          traderId: "",
          totalAvilableToBuy: "",
          maxBuyNum: "",
          sellNum: "",
          totalMoney: "",
          sellMoney: "",
          sellRemark: ""
        }
      },

      SellCouponsModalData_detial: {
        type: "add",
        id: null,
        name: "",
        areaName: "",
        CouponList: [],
        inputParks: [],
        balanceType: "0",
        sellFromTo: "",
        validFromTo: "",
        validDay: "",
        couponType: "0",
        faceValue: "",
        originalPrice: "",
        realPrice: "",
        useRuleMin: "",
        useRuleMax: "",
        totalNum: "",
        remark: "",
        isLimitTotal: "0",
        couponRule: "0",
        useParkingFee: "0"
      },
      mainDatarules: {
        coupon: [{
          required: true,
          message: "请选择优惠券",
          trigger: "change"
        }],
        traderName: [{
          required: true,
          message: "请选择商户名称",
          trigger: "change"
        }],
        sellMoney: [{
          validator: checkMoney,
          trigger: "change"
        }],
        sellNum: [{
          required: true,
          validator: checkNumber,
          trigger: "change"
        }]
      },
      refundrules: {
        refundMoney: [{
          validator: checkRefundMoney,
          trigger: "change"
        }]
      },
      //prop-返回数据的字段名称   proisNotInter:true,pNameisNotInter:true,，name-查询字段传参名称    text-显示名称  //initHidden  初始化不显示
      searchList: [{
          type: "text",
          isShow: false,
          name: "traderName",
          text: "商家名称",
          value: ""
        },
        {
          type: "text",
          isShow: false,
          name: "tmpName",
          text: "优惠券名称",
          value: ""
        },
        {
          type: "text",
          isShow: false,
          name: "sellerName",
          text: "销售人",
          value: ""
        },
        {
          type: "datePicker",
          isShow: false,
          name: "query_time",
          text: "有效期",
          propName: "createTimeStart,createTimeEnd",
          value: "",
          style: {
            width: "360px"
          }
        }
      ],
      theadsInfo: [
        // { index: 0, isShow: false, prop: "reno", text: "序号", width: 64 },
        // {
        //   index: 1,
        //   isShow: false,
        //   prop: "id",
        //   text: "销售ID",
        //   sortable: true,
        //   minWidth: 30
        // },
        {
          index: 1,
          isShow: false,
          prop: "tmpName",
          text: "优惠券名称",
          sortable: true,
          minWidth: 50
        },
        {
          index: 2,
          isShow: false,
          prop: "traderName",
          text: "商家名称",
          sortable: true,
          minWidth: 50
        },
        {
          index: 3,
          isShow: false,
          prop: "sellNum",
          text: "销售数量",
          sortable: true
        },
        {
          index: 4,
          isShow: false,
          prop: "sellMoney",
          text: "金额(元)",
          sortable: true
        },
        {
          index: 5,
          isShow: false,
          prop: "grantNum",
          text: "已发放数量",
          sortable: true
        },
        {
          index: 6,
          isShow: false,
          prop: "usedNum",
          text: "已使用数量",
          sortable: true
        },
        {
          index: 7,
          isShow: false,
          prop: "lockedNum",
          text: "车主未领取",
          sortable: true
        },
        // { index: 8, isShow: false, prop: 'couponSn', text: '优惠券编号', sortable: true, minWidth: 180 },
        {
          index: 8,
          isShow: false,
          prop: "expiredRefundNum",
          text: "逾期回收数量",
          sortable: true
        },
        {
          index: 9,
          isShow: false,
          prop: "couponCode",
          text: "优惠券代码",
          sortable: true,
          minWidth: 65,
          initHidden: true
        },
        {
          index: 10,
          isShow: false,
          prop: "sellerName",
          text: "销售人",
          sortable: true,
          minWidth: 50,
          initHidden: true
        },
        {
          index: 11,
          isShow: false,
          prop: "createTime",
          text: "销售时间",
          sortable: true,
          minWidth: 80,
          initHidden: true
        },
        {
          index: 12,
          isShow: false,
          prop: "transationNum",
          text: "交易单号",
          sortable: true,
          minWidth: 100,
          initHidden: true
        },
        {
          index: 13,
          isShow: false,
          prop: "sellRemark",
          text: "销售备注",
          sortable: true,
          minWidth: 50,
          initHidden: true
        },
        {
          index: 14,
          isShow: false,
          prop: "refundNum",
          text: "已退数量",
          sortable: true,
          initHidden: true
        },
        {
          index: 15,
          isShow: false,
          prop: "refunderName",
          text: "退款人",
          sortable: true,
          minWidth: 50,
          initHidden: true
        },
        {
          index: 16,
          isShow: false,
          prop: "refundTime",
          text: "退款时间",
          sortable: true,
          minWidth: 80,
          initHidden: true
        },
        {
          index: 17,
          isShow: false,
          prop: "refundMoney",
          text: "退款额(元)",
          sortable: true,
          initHidden: true
        },
        {
          index: 18,
          isShow: false,
          prop: "refundRemark",
          text: "退款备注",
          sortable: true,
          minWidth: 50,
          initHidden: true
        }
      ],
      tbodysInfo: []
    };
  },
  methods: {
    confirmSearch(params) {
      this.getList();
    }
  }
};
</script>

<style lang="less" scoped>
@import "../../assets/less/libs/zTreeStyle.css";
@import "./less/c_sell.less";

.row-item {
  display: flex;

  >div {
    &.el-form-item {
      &:last-child {
        margin-left: 30px;
      }
    }
  }
}
</style>
